import { createApp } from 'vue'
import App from './App.vue'
import '@/assets/base.scss'
import '@/assets/iconfont.css'
import '@/assets/element-plus-theme.scss'
import '@/assets/nprogress-theme.scss'
import { createPinia } from 'pinia'
import router from './router'
import 'element-plus/dist/index.css'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import http from './http'
import { BranchSelectorDialog, UserSelectorDialog, UserBranchPicker, BranchTree } from '@nmgolden/address-book-picker'
import '@nmgolden/address-book-picker/style.css'
import { createHttpClient } from '@nmgolden/http-client'
import Initable from '@/components/initable'

const app = createApp(App)
app.use(router)
app.use(createPinia())
app.provide('http', http)
app.use(ElementPlus, {
  locale: zhCn
})
// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
// 通讯录选择
app.use(BranchSelectorDialog)
app.use(UserSelectorDialog)
app.use(UserBranchPicker)
app.use(BranchTree)
app.use(Initable)

app.provide('httpClient', createHttpClient({ baseUrl: import.meta.env.VITE_API_PREFIX }))
app.mount('#app')
